package com.xxx.coll;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;

/**
 * @version v1.0
 * @Description:
 * @Author zhanzhongxin
 * @Date 2021/7/22 10:10
 * @Copyright 博为峰
 */
public class CollectionsDemo {
    public static void main(String[] args) {
        ArrayList<Student> students = new ArrayList<>();
        students.add(new Student("zhangsan", 20));
        students.add(new Student("lisi", 30));
        students.add(new Student("wangwu", 50));
//        Student student = Collections.max(students);
        Collections.sort(students, new ComparatorByLengthImpl());
        Collections.reverse(students);
        Iterator<Student> iterator = students.iterator();
        while (iterator.hasNext()) {
            Student student = iterator.next();
            System.out.println(student.getName());
        }
    }
}
